package com.ge.boot_02_annotation.config;

import com.ge.boot_02_annotation.bean.Cat;
import com.ge.boot_02_annotation.bean.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @BelongsProject: SpringBoot
 * @BelongsPackage: com.ge.boot_02_annotation.config
 * @Author: gejingyu
 * @Date: 2024/1/23
 * @Description: 测试 组件注册注解
 */

@Configuration
public class AppConfig {

    /**
     * 替代XML中的bean标签
     */
    @Bean
    public User user01(){
        User user = new User();
        user.setId(1L);
        user.setName("zhangSan");
        return user;
    }

    /**
     * 多实例bean
     */
    @Scope(value = "prototype")
    @Bean
    public Cat cat(){
        return new Cat();
    }
}
